* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgb(13, 13, 82);
}

.container {
  position: relative;
  transform: skewY(-20deg);
  animation: animation 5s linear infinite;
}

@keyframes animation {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

.container .cube {
  position: relative;
  z-index: 2;
}
.container .cube:nth-child(2) {
  translate: -60px -60px;
  z-index: 1;
}
.container .cube:nth-child(3) {
  translate: 60px 60px;
  z-index: 3;
}
.container .cube {
  position: relative;
  z-index: 2;
}

.container .cube div:nth-child(2) {
  translate: 0px -80px;
  z-index: 3;
}

.container .cube div:nth-child(3) {
  translate: 0px 80px;
  z-index: 1;
}

.container .cube div {
  display: flex;
  position: absolute;
  gap: 40px;
}

.container .cube div span {
  position: absolute;
  width: 50px;
  height: 50px;
  display: inline-block;
  background-color: rgb(219, 219, 219);
  z-index: 2;
  /* 所有的动画都延迟 */
  transition: 1.5s;
  translate: calc(80px * var(--i));
}

.container .cube div span:hover {
  /* 鼠标hover的时候不需要延迟 */
  transition: 0s;
  background-color: red;
  filter: drop-shadow(0 0 30px red);
}

.container .cube div span::before {
  content: '';
  position: absolute;
  width: 40px;
  height: 100%;
  top: 0;
  left: -40px;
  display: inline-block;
  background-color: rgb(254, 254, 254);
  transform-origin: right;
  transform: skewY(45deg);
  transition: 1.5s;
}

.container .cube div span:hover::before {
  transition: 0s;
  background-color: rgb(255, 92, 102);
}

.container .cube div span::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 40px;
  left: 0;
  top: -40px;
  display: inline-block;
  background-color: rgb(241, 241, 241);
  transform-origin: bottom;
  transform: skewX(45deg);
  transition: 1.5s;
}

.container .cube div span:hover::after {
  transition: 0s;
  background-color: rgb(235, 67, 78);
}
